Repository navigation
fix: preserve switch boundaries before lambda results - #39
Merged
Merged
Conversation
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A switch result lambda can absorb the preceding rule arrow into the case label or guard. For example,
case A + B -> value -> value + 2produces a lambda inside the label without a syntax error. Twelve compiler-valid forms in the regression fixture have this incorrect boundary.Requirements
Customer Summary
Switch rules returning lambdas now keep their constant expressions and guards separate from the result lambda, including arithmetic, unary, conditional and cast expressions.
Technical Summary
grammar.jsgiveslambda_expressionthe lowest named precedence and removes its obsolete conflict with primary expressions. The generated parser retains the public node schema. Two corpus cases cover switch results and independent lambda contexts, including legitimate lambdas nested inside guards.Testing
bun run verifypassed with zero code-gauge violations. Rust unit and documentation tests passed. Incremental fuzzing passed all 165 cases with 100 iterations and ten edits, explicitly using seed 1.Notes
The upstream root-expression exclusions alone miss nested arithmetic operands, so this change uses precedence instead. Compiler-rejected assignment guards and an unparenthesized expression-bodied cast-lambda guard are excluded from the positive fixtures. The measured controls establish scoped parity rather than universal grammar equivalence.